"""
    定义员工管理器
        1：管理所有员工
        2：计算所有员工工资
        
    员工：
        程序员：底薪 + 项目分红
        销售： 底薪 + 销售额 x 0.05
        软件测试。。。。
    要求：
        增加新岗位，员工管理器不变
"""


class Staff_manager:
    def __init__(self):
        self.staff_list = []

    def get_staff_list(self):
        """
            查看所有员工
        """
        return self.staff_list

    def add_staff(self, staff):
        """
            添加员工
        """
        if isinstance(staff, Prosion):
            self.staff_list.append(staff)
        else:
            raise ValueError("必须是Prosion类或是他的子类！")

    def get_staff_staff_list(self):
        """
            计算所有员工工资
        """
        salary = 0
        for i in self.staff_list:
            salary += i.staff_data()
        return salary


class Prosion:
    def staff_data(self):
        pass


class Programmer(Prosion):
    def __init__(self, name, basic, share):
        self.name = name
        self.basic = basic
        self.share = share

    def staff_data(self):
        """
            程序员工资计算
        """
        return self.basic + self.share


class Salesman(Prosion):
    def __init__(self, name, basic, saleroom):
        self.name = name
        self.basic = basic
        self.saleroom = saleroom

    def staff_data(self):
        """
            销售工资计算
        """
        return self.basic + (self.saleroom * 0.05)


zs = Programmer("张三", 5000, 20000)
ls = Salesman('李四', 5000, 40000)
glq = Staff_manager()
glq.add_staff(zs)
glq.add_staff(ls)
print(glq.get_staff_staff_list())
for i in glq.get_staff_list():
    print(i.__dict__)
